home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / hity wydania / Ubuntu 9.10 PL / karmelkowy-koliberek-desktop-9.10-i386-PL.iso / casper / filesystem.squashfs / usr / lib / linux-boot-probes / 50mounted-tests
Text File  |  2009-09-14  |  2KB  |  70 lines

  1. #!/bin/sh
  2. # Sub-tests that require a mounted partition.
  3. . /usr/share/os-prober/common.sh
  4. set -e
  5.  
  6. partition=$1
  7.  
  8. tmpmnt=/var/lib/os-prober/mount
  9. if [ ! -d $tmpmnt ]; then
  10.     mkdir $tmpmnt
  11. fi
  12.  
  13. types="$(fs_type "$partition")" || types=NOT-DETECTED
  14. if [ "$types" = NOT-DETECTED ]; then
  15.     debug "$1 type not recognised; skipping"
  16.     exit 0
  17. elif [ "$types" = swap ]; then
  18.     debug "$1 is a swap partition; skipping"
  19.     exit 0
  20. elif [ "$types" = crypto_LUKS ]; then
  21.     debug "$1 is a LUKS partition; skipping"
  22.     exit 0
  23. elif [ "$types" = ntfs ]; then
  24.     if type ntfs-3g >/dev/null 2>&1; then
  25.         types='ntfs-3g ntfs'
  26.     fi
  27. elif [ -z "$types" ]; then
  28.     if type cryptsetup >/dev/null 2>&1 && \
  29.        cryptsetup luksDump "$partition" >/dev/null 2>&1; then
  30.         debug "$1 is a LUKS partition; skipping"
  31.         exit 0
  32.     fi
  33.     types="$(grep -v nodev /proc/filesystems)"
  34. fi
  35.  
  36. for type in $types; do
  37.     if mount -o ro -t $type $partition $tmpmnt 2>/dev/null; then
  38.         mountboot="$(linux_mount_boot "$partition" "$tmpmnt")"
  39.         bootpart="${mountboot%% *}"
  40.         mounted="${mountboot#* }"
  41.         
  42.         for test in /usr/lib/linux-boot-probes/mounted/*; do
  43.             if [ -f $test ] && [ -x $test ]; then
  44.                 debug "running $test $partition $bootpart $tmpmnt $type"
  45.                 if $test "$partition" "$bootpart" "$tmpmnt" "$type"; then
  46.                     debug "$test succeeded"
  47.                     umount $tmpmnt/boot 2>/dev/null || true     
  48.                     if ! umount $tmpmnt; then
  49.                         warn "failed to umount $tmpmnt"
  50.                     fi
  51.                     rmdir $tmpmnt || true
  52.                     exit 0
  53.                 fi
  54.             fi
  55.         done
  56.         
  57.         umount $tmpmnt/boot 2>/dev/null || true     
  58.         if ! umount $tmpmnt; then
  59.             warn "failed to umount $tmpmnt"
  60.         fi
  61.  
  62.         break
  63.     fi
  64. done
  65.  
  66. rmdir $tmpmnt || true
  67.  
  68. # No tests found anything.
  69. exit 1
  70.